<!doctype html>
<html class="default no-js">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>burstjs - The Burstcoin Reference Library</title>
	<meta name="description" content="">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<meta name="robots" content="index, follow">
	<link rel="stylesheet" href="assets/css/main.css">
	<link rel="stylesheet" href="assets/css/custom.css">
</head>
<body>
<a href="https://github.com/burst-apps-team/phoenix/tree/master/lib" class="github-corner" aria-label="View source on GitHub">
	<svg width="80" height="80" viewBox="0 0 250 250"
	style="fill:rgba(3, 155, 229, 0.90); color:#fff; position: absolute; top: 0; border: 0; left: 0; z-index: 2; transform: scale(-1, 1);"
	aria-hidden="true">
	<path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
	<path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"
	fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path>
	<path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"
	fill="currentColor" class="octo-body"></path>
	</svg>
</a>
<header>
	<div class="tsd-page-toolbar">
		<div class="container">
			<div class="tsd-logo-wrapper">
				<a href="index.html" class="title">
					<img id="tsd-burstjs-logo" alt="burstjs" src="assets/images/burstjs.png">
				</a>
				<a href="https://www.npmjs.com/package/@burstjs/core">
					<img id="tsd-npm-badge" alt="npm"
					src="https://img.shields.io/npm/v/@burstjs/core.svg?style=for-the-badge">
				</a>
			</div>
			<div class="table-wrap">
				<div class="table-cell" id="tsd-search" data-index="assets/js/search.js"
				data-base=".">
				<div class="field">
					<label for="tsd-search-field" class="tsd-widget search no-caption">Search</label>
					<input id="tsd-search-field" type="text"/>
				</div>
				<ul class="results">
					<li class="state loading">Preparing search index...</li>
					<li class="state failure">The search index is not available</li>
				</ul>
			</div>
			<div class="table-cell" id="tsd-widgets">
				<div id="tsd-filter">
					<a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a>
					<div class="tsd-filter-group">
						<div class="tsd-select" id="tsd-filter-visibility">
							<span class="tsd-select-label">All</span>
							<ul class="tsd-select-list">
								<li data-value="public">Public</li>
								<li data-value="protected">Public/Protected</li>
								<li data-value="private" class="selected">All</li>
							</ul>
						</div>
						<input type="checkbox" id="tsd-filter-inherited" checked/>
						<label class="tsd-widget" for="tsd-filter-inherited">Inherited</label>
						<input type="checkbox" id="tsd-filter-externals" checked/>
						<label class="tsd-widget" for="tsd-filter-externals">Externals</label>
					</div>
				</div>
				<a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a>
			</div>
		</div>
	</div>
	</div>
	<div class="tsd-page-title">
		<div class="container">
			<ul class="tsd-breadcrumb">
				<li>
					<a href="globals.html">Globals</a>
				</li>
			</ul>
			<h1> burstjs - The Burstcoin Reference Library</h1>
		</div>
	</div>
</header>
<div class="container container-main">
	<div class="row">
		<div class="col-8 col-content">
			<div class="tsd-panel tsd-typography">
				<img src="./assets/images/burstjs.png" alt="burstjs" width="600" align="middle" />
				<blockquote>
					<p>The BurstCoin Type/Javascript Reference Library</p>
				</blockquote>
				<hr>
				<p><a href="https://lernajs.io/"><img src="https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg" alt="lerna"></a>
					<a href="https://www.codacy.com/app/ohager/phoenix?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=burst-apps-team/phoenix&amp;utm_campaign=Badge_Grade"><img src="https://api.codacy.com/project/badge/Grade/81a6119af03d4a7e8a55c65999884709" alt="Codacy Badge"></a>
					<a href="https://travis-ci.org/burst-apps-team/phoenix"><img src="https://travis-ci.org/burst-apps-team/phoenix.svg?branch=develop" alt="Build Status"></a>
					<a href="https://snyk.io/test/github/burst-apps-team/phoenix?targetFile=lib%2Fpackage.json"><img src="https://snyk.io/test/github/burst-apps-team/phoenix/badge.svg?targetFile=lib%2Fpackage.json" alt="Known Vulnerabilities"></a>
					<a href="https://codecov.io/gh/burst-apps-team/phoenix"><img src="https://codecov.io/gh/burst-apps-team/phoenix/branch/develop/graph/badge.svg" alt="codecov"></a>
				<a href="https://www.jsdelivr.com/package/npm/@burstjs/core"><img src="https://data.jsdelivr.com/v1/package/npm/@burstjs/core/badge" alt="jsDelivr"></a></p>
				<h2 id="npm"><img src="https://img.shields.io/npm/l/@burstjs/core?color=blue&label=license" alt="NPM"></h2>
				<p><code>@burstjs</code> is a modern library written in Typescript providing common functionalities for <em>browsers</em> and <em>nodejs</em> to interact with the <a href="https://burstcoin.community/">BurstCoin blockchain</a>,
				an advanced community-driven blockchain technology.</p>
				<p>This library is part of the Phoenix project, i.e. the new Burstcoin Wallet for Web, Desktop, Android, and iOS.</p>
				<h2 id="packages">Packages</h2>
				<p>The library is separated in the following packages</p>
				<ul>
					<li><a href="./modules/core.html">@burstjs/core</a> The main package providing an extense API for blockchain interaction</li>
					<li><a href="./modules/crypto.html">@burstjs/crypto</a> A package providing BURST relevant crypto functions</li>
					<li><a href="./modules/util.html">@burstjs/util</a> A package providing useful functions, e.g. common conversion functions </li>
					<li><a href="./modules/http.html">@burstjs/http</a> A package providing a <em>simplified</em> Http layer, with consistent response types, and exception handling</li>
				</ul>
				<h2 id="installation">Installation</h2>
				<p><code>@burstjs</code> aims modern browsers and nodejs &gt; v10, but can also be used as bundled JavaScript using <code>&lt;script&gt;</code> </p>
				<h3 id="using-with-nodejs-and-or-modern-web-frameworks">Using with NodeJS and/or modern web frameworks</h3>
				<p>Install using <a href="https://www.npmjs.org/">npm</a>:</p>
				<pre><code><span class="hljs-built_in">npm</span> install @burstjs/core
<span class="hljs-built_in">npm</span> install @burstjs/crypto (optional)
<span class="hljs-built_in">npm</span> install @burstjs/util (optional)
<span class="hljs-built_in">npm</span> install @burstjs/http (optional)</code></pre><p>or using <a href="https://yarnpkg.com/">yarn</a>:</p>
				<pre><code class="language-yarn">yarn add @burstjs/core
yarn add @burstjs/crypto (optional)
yarn add @burstjs/util (optional)
yarn add @burstjs/http (optional)</code></pre>
				<blockquote>
					<p>Usually, you won&#39;t need to install other packages than <code>@burstjs/core</code>, which uses the other packages.</p>
				</blockquote>
				<p>or using <a href="https://yarnpkg.com/">yarn</a>:</p>
				<pre><code class="language-yarn">yarn add @burstjs/core
yarn add @burstjs/crypto (optional)
yarn add @burstjs/util (optional)
yarn add @burstjs/http (optional)</code></pre>
				<h3 id="using-in-classic-script">Using in classic <code>&lt;script&gt;</code></h3>
				<p>Each package is available as bundled standalone library using IIFE.
					This way <em>burstJS</em> can be used also within <code>&lt;script&gt;</code>-Tags.
				This might be useful for Wordpress and/or other PHP applications.</p>
				<p>Just import one of the packages using the HTML <code>&lt;script&gt;</code> tag.</p>
				<p><code>&lt;script src=&#39;https://cdn.jsdelivr.net/npm/@burstjs/core/dist/burstjs.min.js&#39;&gt;&lt;/script&gt;</code></p>
				<p><code>&lt;script src=&#39;https://cdn.jsdelivr.net/npm/@burstjs/crypto/dist/burstjs.crypto.min.js&#39;&gt;&lt;/script&gt;</code></p>
				<p><code>&lt;script src=&#39;https://cdn.jsdelivr.net/npm/@burstjs/http/dist/burstjs.http.min.js&#39;&gt;&lt;/script&gt;</code></p>
				<p><code>&lt;script src=&#39;https://cdn.jsdelivr.net/npm/@burstjs/util/dist/burstjs.util.min.js&#39;&gt;&lt;/script&gt;</code></p>
				<p>Due to the way a package is imported following global variables are provided</p>
				<table>
					<thead>
						<tr>
							<th>Package</th>
							<th>Variable</th>
						</tr>
					</thead>
					<tbody><tr>
							<td>core</td>
							<td><code>b$</code></td>
						</tr>
						<tr>
							<td>crypto</td>
							<td><code>b$crypto</code></td>
						</tr>
						<tr>
							<td>http</td>
							<td><code>b$http</code></td>
						</tr>
						<tr>
							<td>util</td>
							<td><code>b$util</code></td>
						</tr>
				</tbody></table>
				<p>Examples:</p>
				<pre><code class="language-js"><span class="hljs-comment">// using core</span>
<span class="hljs-keyword">const</span> api = b$.composeApi({
  <span class="hljs-attr">nodeHost</span>: <span class="hljs-string">"http://at-testnet.burst-alliance.org:6876"</span>,
  <span class="hljs-attr">apiRootUrl</span>: <span class="hljs-string">"/burst"</span>
});

api.network.getBlockchainStatus().then(<span class="hljs-built_in">console</span>.log);</code></pre>
				<pre><code class="language-js"><span class="hljs-comment">// using crypto</span>
<span class="hljs-built_in">console</span>.log(b$crypto.hashSHA256(<span class="hljs-string">"test"</span>))</code></pre>
				<pre><code class="language-js"><span class="hljs-comment">// using util</span>
<span class="hljs-keyword">const</span> value = b$util.convertNumberToNQTString(<span class="hljs-number">1000</span>)</code></pre>
				<pre><code class="language-js"><span class="hljs-comment">// using http</span>
<span class="hljs-keyword">const</span> client = <span class="hljs-keyword">new</span> b$http.HttpImpl(<span class="hljs-string">'https://jsonplaceholder.typicode.com/'</span>);
client.get(<span class="hljs-string">'/todos/1'</span>).then(<span class="hljs-built_in">console</span>.log)</code></pre>
				<h2 id="usage">Usage</h2>
				<p>The following example shows how to interact with the blockchain, i.e. getting the balance of a specific account</p>
				<h3 id="es6-nodejs-style">ES6/NodeJS style</h3>
				<p>In a separate file, preferribly <code>index.js</code> or <code>main.js</code> write your entry point like this:</p>
				<pre><code class="language-js"><span class="hljs-keyword">import</span> {composeApi, ApiSettings} <span class="hljs-keyword">from</span> <span class="hljs-string">'@burstjs/core'</span>
<span class="hljs-keyword">import</span> {convertNQTStringToNumber} <span class="hljs-keyword">from</span> <span class="hljs-string">'@burstjs/util'</span>

<span class="hljs-keyword">const</span> apiSettings = <span class="hljs-keyword">new</span> ApiSettings(<span class="hljs-string">'http://at-testnet.burst-alliance.org:6876'</span>, <span class="hljs-string">'burst'</span>);
<span class="hljs-keyword">const</span> api = composeApi(apiSettings);

<span class="hljs-comment">// this self-executing file makes turns this file into a starting point of your app</span>

<span class="hljs-function">(<span class="hljs-params"><span class="hljs-keyword">async</span> (</span>) =&gt;</span> {
  <span class="hljs-keyword">try</span>{
    <span class="hljs-keyword">const</span> {balanceNQT} = <span class="hljs-keyword">await</span> api.account.getAccountBalance(<span class="hljs-string">'13036514135565182944'</span>)
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`Account Balance: <span class="hljs-subst">${convertNQTStringToNumber(balanceNQT)}</span> BURST`</span>)  
  }
  <span class="hljs-keyword">catch</span>(e){ <span class="hljs-comment">// e is of type HttpError (as part of @burstjs/http)</span>
    <span class="hljs-built_in">console</span>.error(<span class="hljs-string">`Whooops, something went wrong: <span class="hljs-subst">${e.message}</span>`</span>)      
  }
})()
</code></pre>
				<h3 id="script-style"><code>&lt;script&gt;</code> style</h3>
				<pre><code class="language-js"><span class="hljs-keyword">const</span> apiSettings = <span class="hljs-keyword">new</span> b$.ApiSettings(<span class="hljs-string">'http://at-testnet.burst-alliance.org:6876'</span>, <span class="hljs-string">'burst'</span>);
<span class="hljs-keyword">const</span> api = b$.composeApi(apiSettings);


api.account.getAccountBalance(<span class="hljs-string">'13036514135565182944'</span>)
    .then( <span class="hljs-function"><span class="hljs-params">balance</span> =&gt;</span> {
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`Account Balance: <span class="hljs-subst">${b$util.convertNQTStringToNumber(balance.balanceNQT)}</span> BURST`</span>)  

    })
    .catch(<span class="hljs-function"><span class="hljs-params">e</span> =&gt;</span> { <span class="hljs-comment">// e is of type HttpError (as part of @burstjs/http)</span>
        <span class="hljs-built_in">console</span>.error(<span class="hljs-string">`Whooops, something went wrong: <span class="hljs-subst">${e.message}</span>`</span>)      
    })
</code></pre>
			</div>
		</div>
		<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
			<nav class="tsd-navigation primary">
				<ul>
					<li class="globals  ">
						<a href="globals.html"><em>Globals</em></a>
					</li>
					<li class=" tsd-kind-external-module">
						<a href="modules/core.html">core</a>
					</li>
					<li class=" tsd-kind-external-module">
						<a href="modules/crypto.html">crypto</a>
					</li>
					<li class=" tsd-kind-external-module">
						<a href="modules/http.html">http</a>
					</li>
					<li class=" tsd-kind-external-module">
						<a href="modules/util.html">util</a>
					</li>
				</ul>
			</nav>
			<nav class="tsd-navigation secondary menu-sticky">
				<ul class="before-current">
				</ul>
			</nav>
		</div>
	</div>
</div>
<footer class="with-border-bottom">
	<div class="container">
		<h2>Legend</h2>
		<div class="tsd-legend-group">
			<ul class="tsd-legend">
				<li class="tsd-kind-module"><span class="tsd-kind-icon">Module</span></li>
				<li class="tsd-kind-object-literal"><span class="tsd-kind-icon">Object literal</span></li>
				<li class="tsd-kind-variable"><span class="tsd-kind-icon">Variable</span></li>
				<li class="tsd-kind-function"><span class="tsd-kind-icon">Function</span></li>
				<li class="tsd-kind-function tsd-has-type-parameter"><span class="tsd-kind-icon">Function with type parameter</span></li>
				<li class="tsd-kind-index-signature"><span class="tsd-kind-icon">Index signature</span></li>
				<li class="tsd-kind-type-alias"><span class="tsd-kind-icon">Type alias</span></li>
			</ul>
			<ul class="tsd-legend">
				<li class="tsd-kind-enum"><span class="tsd-kind-icon">Enumeration</span></li>
				<li class="tsd-kind-enum-member"><span class="tsd-kind-icon">Enumeration member</span></li>
				<li class="tsd-kind-property tsd-parent-kind-enum"><span class="tsd-kind-icon">Property</span></li>
				<li class="tsd-kind-method tsd-parent-kind-enum"><span class="tsd-kind-icon">Method</span></li>
			</ul>
			<ul class="tsd-legend">
				<li class="tsd-kind-interface"><span class="tsd-kind-icon">Interface</span></li>
				<li class="tsd-kind-interface tsd-has-type-parameter"><span class="tsd-kind-icon">Interface with type parameter</span></li>
				<li class="tsd-kind-constructor tsd-parent-kind-interface"><span class="tsd-kind-icon">Constructor</span></li>
				<li class="tsd-kind-property tsd-parent-kind-interface"><span class="tsd-kind-icon">Property</span></li>
				<li class="tsd-kind-method tsd-parent-kind-interface"><span class="tsd-kind-icon">Method</span></li>
				<li class="tsd-kind-index-signature tsd-parent-kind-interface"><span class="tsd-kind-icon">Index signature</span></li>
			</ul>
			<ul class="tsd-legend">
				<li class="tsd-kind-class"><span class="tsd-kind-icon">Class</span></li>
				<li class="tsd-kind-class tsd-has-type-parameter"><span class="tsd-kind-icon">Class with type parameter</span></li>
				<li class="tsd-kind-constructor tsd-parent-kind-class"><span class="tsd-kind-icon">Constructor</span></li>
				<li class="tsd-kind-property tsd-parent-kind-class"><span class="tsd-kind-icon">Property</span></li>
				<li class="tsd-kind-method tsd-parent-kind-class"><span class="tsd-kind-icon">Method</span></li>
				<li class="tsd-kind-accessor tsd-parent-kind-class"><span class="tsd-kind-icon">Accessor</span></li>
				<li class="tsd-kind-index-signature tsd-parent-kind-class"><span class="tsd-kind-icon">Index signature</span></li>
			</ul>
			<ul class="tsd-legend">
				<li class="tsd-kind-constructor tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited constructor</span></li>
				<li class="tsd-kind-property tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited property</span></li>
				<li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited method</span></li>
				<li class="tsd-kind-accessor tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited accessor</span></li>
			</ul>
			<ul class="tsd-legend">
				<li class="tsd-kind-property tsd-parent-kind-class tsd-is-protected"><span class="tsd-kind-icon">Protected property</span></li>
				<li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected"><span class="tsd-kind-icon">Protected method</span></li>
				<li class="tsd-kind-accessor tsd-parent-kind-class tsd-is-protected"><span class="tsd-kind-icon">Protected accessor</span></li>
			</ul>
			<ul class="tsd-legend">
				<li class="tsd-kind-property tsd-parent-kind-class tsd-is-private"><span class="tsd-kind-icon">Private property</span></li>
				<li class="tsd-kind-method tsd-parent-kind-class tsd-is-private"><span class="tsd-kind-icon">Private method</span></li>
				<li class="tsd-kind-accessor tsd-parent-kind-class tsd-is-private"><span class="tsd-kind-icon">Private accessor</span></li>
			</ul>
			<ul class="tsd-legend">
				<li class="tsd-kind-property tsd-parent-kind-class tsd-is-static"><span class="tsd-kind-icon">Static property</span></li>
				<li class="tsd-kind-call-signature tsd-parent-kind-class tsd-is-static"><span class="tsd-kind-icon">Static method</span></li>
			</ul>
		</div>
	</div>
</footer>
<div class="container tsd-generator">
	<p>Generated using <a href="http://typedoc.org/" target="_blank">TypeDoc</a></p>
</div>
<div class="overlay"></div>
<script src="assets/js/main.js"></script>
<script>if (location.protocol == 'file:') document.write('<script src="assets/js/search.js"><' + '/script>');</script>
</body>
</html>